<?php

namespace App\Controller\Admin\System;

use App\Controller\Admin\BaseController;
use App\Service\System\ChangelogService;
use Hyperf\Di\Annotation\Inject;
use Yj\Apidog\Annotation\ApiController;
use Yj\Apidog\Annotation\FormData;
use Yj\Apidog\Annotation\PostApi;

/**
 * @ApiController(prefix="admin/system/changelog")
 */
class ChangelogController extends BaseController
{

    /**
     * @Inject()
     * @var ChangelogService
     */
    protected $changelogService;

    /**
     * @PostApi(path="lists")
     */
    public function lists(){
        $params = $this->getParams();
        $data = $this->changelogService->lists($params);
        _SUCCESS($data);
    }

    /**
     * @PostApi(path="add")
     * @FormData(key="content")
     * @FormData(key="version")
     */
    public function add(){
        $params = $this->getParams();
        $this->changelogService->add($params);
        _SUCCESS();
    }

    /**
     * @PostApi(path="edit")
     * @FormData(key="content")
     * @FormData(key="version")
     * @FormData(key="id")
     */
    public function edit(){
        $params = $this->getParams();
        $this->changelogService->edit($params->get('id'),$params->except('id'));
        _SUCCESS();
    }

    /**
     * @PostApi(path="del")
     * @FormData(key="id")
     */
    public function del(){
        $id = $this->getParams()->get('id');
        $this->changelogService->del($id);
        _SUCCESS();
    }

}